﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Castle.ActiveRecord;

namespace SinsenWeb.Models
{
    public class EntityBase<T>: ActiveRecordBase<T> 
    {
        public static new List<T> FindAll()
        {
            return ActiveRecordBase<T>.FindAll().ToList();
        }

        public static T Get(string id)
        {
            try
            {
                return Find(int.Parse(id));
            }
            catch
            {
                return default(T);
            }
        }

        public static List<T> FindAll(List<int> ids)
        {
            var list = new List<T>();
            foreach (var id in ids)
            {
                list.Add(Find(id));
            }
            return list;
        }

    }
}
